﻿using System;
using System.Collections.Generic;
using System.Text;
using UtilZ.Dotnet.Ex.Base;
using UtilZ.Dotnet.Ex.Communication.Base;
using UtilZ.Dotnet.Ex.Communication.Net.Base;

namespace UtilZ.Dotnet.Ex.Communication.Net.Telnet
{
    /// <summary>
    /// TelnetClient监听客户端接口
    /// </summary>
    public interface IListenTelnetClient : IDisposable
    {
        /// <summary>
        /// 登录用户信息，不用登录时为null
        /// </summary>
        TelnetUserInfo UserInfo { get; }

        /// <summary>
        /// telnet连接状态改变事件
        /// </summary>
        event EventHandler<NetConnectedChangedArgs> ConnectChanged;

        /// <summary>
        /// telnet客户端连接状态
        /// </summary>
        ConnectionStatus Status { get; }

        /// <summary>
        /// 获取或设置消息编码
        /// </summary>
        Encoding MessageEncoding { get; set; }

        /// <summary>
        /// 获取Telnet客户端操作系统类型
        /// </summary>
        OSPlatformID Platform { get; set; }

        /// <summary>
        /// 发送消息
        /// </summary>
        /// <param name="message">消息</param>
        void SendMessage(string message);

        /// <summary>
        /// 发送数据
        /// </summary>
        /// <param name="data">数据</param>
        /// <param name="offset">发送起始位置</param>
        /// <param name="length">数据长度</param>
        void Send(byte[] data, int offset = -1, int length = -1);

        /// <summary>
        /// 断开连接命令
        /// </summary>
        void Disconnect();

        /// <summary>
        /// 清空命令历史
        /// </summary>
        void ClearCommandHistory();

        /// <summary>
        /// 清空屏幕
        /// </summary>
        /// <param name="lineCount">清空行数</param>
        void ClearScreen(int lineCount);

        /// <summary>
        /// 设置历史命令缓存大小
        /// </summary>
        /// <param name="capcity"></param>
        void SetHistoryCommandCapcity(int capcity);

        /// <summary>
        /// 获取Telnet信息
        /// </summary>
        /// <returns></returns>
        string GetTelnetInfo();
    }
}
